home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / UTILITY1 / MSWSRC35.ZIP / MAIN.CPP < prev    next >
C/C++ Source or Header  |  1993-10-12  |  39KB  |  1,463 lines

  1. #include "allwind.h"
  2.  
  3. CUTMAP *CutBmp;           /* Pointer to Bit Cut memory array malloc on init */
  4. int CutIndex = 0;       /* Pointer into CutBmp initially "ClipBoard" */
  5.  
  6. HANDLE HashHandle=0;       /* Handle to Hashtable */
  7. HANDLE StackHandle=0;      /* Handle to Gargebage Collector Stack */
  8.  
  9. HBITMAP MemoryBitMap;      /* Backing store bitmap */
  10. HBITMAP AreaMemoryBitMap;  /* Used to store active area of backing store */
  11.  
  12. HICON hCursor;             /* handle for saved cursor */
  13. HICON hCursorWait;         /* handle for hour glass cursor */
  14.  
  15. HPALETTE ThePalette;       /* Handle for the single color palette */
  16.  
  17. LPLOGPALETTE MyLogPalette; /* Handle for the single logical color palette */
  18.  
  19. NUMBER the_zoom = 1.0;     /* current zoom factor */
  20. NUMBER ibmoldx;            /* global store for x "From" routine */
  21. NUMBER ibmoldy;            /* global store for y "From" routine */
  22.  
  23. NODE *current_line = NIL;  /* current line to be parsed */
  24.  
  25. char LibPathName[EXE_NAME_MAX_SIZE+1];       /* path to library */
  26. char TempPathName[EXE_NAME_MAX_SIZE+1];      /* path to temp file */
  27. char szHelpFileName[EXE_NAME_MAX_SIZE+1];    /* path to help file */
  28. char MCIHelpFileName[EXE_NAME_MAX_SIZE+1];   /* path to MCI help file */
  29. char SelectedText[MAX_BUFFER_SIZE];          /* buffer for selected text */ 
  30. char YABuffer[MAX_BUFFER_SIZE];              /* Yet Another buffer */
  31. char commandarg[MAX_BUFFER_SIZE];            /* Routine to exec on start */
  32.  
  33. // holds callback code
  34.  
  35. char edit_editexit[MAX_BUFFER_SIZE];         /* callable editor cb */
  36. char mci_callback[MAX_BUFFER_SIZE];          /* MCI callback code */
  37. char *timer_callback[MAX_TIMERS];            /* timer cb malloc'd as needed */
  38. char *mouse_lbuttondown = NULL;              /* Mouse Left button down cb */
  39. char *mouse_lbuttonup = NULL;                /* Mouse Right button up cb */
  40. char *mouse_rbuttondown = NULL;              /* Mouse Left button down cb */
  41. char *mouse_rbuttonup = NULL;                /* Mouse Right button up cb */
  42. char *mouse_mousemove = NULL;                /* Mouse Move cb */
  43. char *keyboard_keydown = NULL;               /* KeyBoard key down */
  44. char *keyboard_keyup = NULL;                 /* KeyBoard key up */
  45.  
  46. HINSTANCE ModulehInstance;                   /* About box instance handle */
  47.  
  48. HWND MainHWindow;                            /* Handle to Main(screen) window */
  49. HWND CmdHWindow;                             /* Handle to commander window */
  50. HWND StatusHWindow;                 /* Handle to status window */
  51. HWND EdtHWindow;                             /* Handle to editor window */
  52.  
  53. /* Handles to each child windows of of the command window */
  54.  
  55. HWND ListHWindow;                         
  56. HWND EditHWindow;                        
  57. HWND ExecuteHWindow;
  58. HWND HaltHWindow;
  59. HWND TraceHWindow;
  60. HWND PauseHWindow;
  61. HWND StatHWindow;
  62. HWND YieldHWindow;
  63. HWND ResetHWindow;
  64.  
  65. /* place holders for windows resources */
  66.  
  67. HBITMAP OldBitmap;
  68. HBITMAP OldBitmap2;
  69.  
  70. HPALETTE OldPalette;
  71. HPALETTE OldPalette2;
  72.  
  73. HPEN OldPen;
  74.  
  75. HBRUSH OldBrush;
  76.  
  77. HFONT OldFont;
  78.  
  79. LOGFONT FontRec;
  80.  
  81. LOGPEN NormalPen;                 /* Handle to "Normal" logical Pen */
  82. LOGPEN ErasePen;                  /* Handle to "Erase" logical Pen */
  83.  
  84. LOGBRUSH FloodBrush;              /* Handle to the "floodfill" brush */
  85. LOGBRUSH ScreenBrush;             /* Handle to the "screen" background brush */
  86.  
  87. RECT FullRect;                    /* Ready rectangle of Full bitmap */
  88. RECT TempRect;                    /* Temp rectangle */
  89.  
  90. PTWindowsObject MainWindowx;      /* Pointer to the Main window */
  91.  
  92. /* Active area dimensions (real and temp) */
  93.  
  94. int PrinterAreaXLow;
  95. int PrinterAreaXHigh;
  96. int PrinterAreaYLow;
  97. int PrinterAreaYHigh;
  98. int TPrinterAreaXLow;
  99. int TPrinterAreaXHigh;
  100. int TPrinterAreaYLow;
  101. int TPrinterAreaYHigh;
  102.  
  103. int GCMAX = 8192;           /* Garbage Collector STack Size (Logo.ini) */
  104. int MAX_PHYS_LINE = 8192;   /* Maximum Physical Line Size (Logo.ini) */
  105. int dpenr;                  /* Current draw pen color red */
  106. int dpeng;                  /* Current draw pen color green */
  107. int dpenb;                  /* Current draw pen color blue */
  108. int dfldr;                  /* Current flood pen color red */
  109. int dfldg;                  /* Current flood pen color green */
  110. int dfldb;                  /* Current flood pen color blue */
  111. int dscnr;                  /* Current screen pen color red */
  112. int dscng;                  /* Current screen pen color green */
  113. int dscnb;                  /* Current screen pen color blue */
  114. int IsDirty = 0;            /* Flag to signal to query user ok to quit */
  115. int NumFonts;               /* Number of system fonts available */
  116. int BitMapWidth  = 1000;    /* Current bitmap size in X */
  117. int BitMapHeight = 1000;    /* Current bitmap size in Y */
  118. int EnablePalette;          /* Flag to signal 256 color mode with palette */
  119. int CustomFlag = 0;         /* Flag to signal Active area is active */
  120. int TCustomFlag = 0;        /* Dynamic copy of CustomFlag */
  121. int Command_OK = 0;         /* Flag to signal it's OK to write to recall box */
  122. int halt_flag = 0;          /* Flag to signal it's OK to halt */
  123. int traceflag = 0;          /* Flag to signal trace button is active */
  124. int pause_flag = 0;         /* Flag to signal pause button is pushed */
  125. int yield_flag = 1;         /* Flag to signal yield state */
  126. int status_flag = 0;        /* Flag to signal status box is poped up */
  127. int MaxWidth = 0;           /* Actual Main window size x */
  128. int MaxHeight = 0;          /* Actual Main window size y */
  129. int xoffset = 0;            /* Used to go from logo to windows coords x */
  130. int yoffset = 0;            /* Used to go from logo to windows coords y */
  131. int JustDidEdit = 0;        /* Flag to signal last command was edit (like) */
  132. int MaxX;                   /* Yet another window size x */
  133. int MaxY;            /* Yet another window size y */
  134. int Time_To_Exit = 0;        /* Flag to signal it's time to exit */
  135. int Time_To_Pause = 0;      /* UCBLOGO? pause flag */
  136. int Time_To_Halt = 0;       /* UCBLOGO? halt flag */
  137. int error_happen;        /* FLag to signal Error happened on edit reload */
  138. int keyboard_on = 0;        /* Flag to signal Keyboard is enabled */
  139. int keyboard_value = 0;     /* Value of Keyboard key */
  140. int mouse_on = 0;           /* Flag to signal Mouse is enabled */
  141. int mouse_posx = 0;         /* Value of Mouse position x */
  142. int mouse_posy = 0;         /* Value of Mouse position y */
  143. int memory_count = 0;       /* Current amount of logo segments malloc'd */
  144. int BaseUnitsx = 0;        /* X Units Windows uses to for units in dialog */
  145. int BaseUnitsy = 0;         /* Y Units Windows uses to for units in dialog */
  146.  
  147. long eval_count = 0;        /* current count of "evaluations" calls */
  148. long scolor = 1;            /* screen color */
  149. long fcolor = 1;            /* flood color */
  150. long pcolor = 1;        /* pen color */
  151. long width = 1;            /* pen width */
  152. long zoom_flag = 0;         /* flag to signal in zoomed state */
  153. long MaxColors = 0;        /* The maximum # of colors available */
  154. long first_init = 0;        /* hack flag to signal one time initialization */
  155.  
  156. LINEX TurtlePoints[3];      /* used to store 3 vertices of turtle */
  157.  
  158. /* File editor members */
  159.  
  160. TMyFileEditWindow::TMyFileEditWindow(PTWindowsObject AParent, LPSTR ATitle)
  161. : TDialog(AParent, ATitle)
  162.    {
  163.    }
  164.  
  165. TMyFileEditWindow::~TMyFileEditWindow()
  166.    {
  167.    }
  168.  
  169. void TMyFileEditWindow::DoAll(RTMessage Msg)
  170.    { 
  171.    
  172.    FileEditAll = 1;
  173.    CloseWindow(TRUE);
  174.    
  175.    }
  176.  
  177. void TMyFileEditWindow::DoCombo(RTMessage Msg)
  178.    { 
  179.    
  180.    if ( Msg.LP.Hi == CBN_DBLCLK )
  181.       {
  182.       CloseWindow(TRUE);
  183.       }
  184.    }
  185.  
  186. BOOL TMyFileEditWindow::CanClose()
  187.    {
  188.    SendDlgItemMsg(ID_FILEEDITCOMBO, WM_GETTEXT, MAX_BUFFER_SIZE, (LONG)SelectedText);
  189.    
  190.    return TRUE;
  191.    }
  192.  
  193. void TMyFileEditWindow::WMInitDialog(RTMessage Msg)
  194.    { 
  195.    NODE *proclst;
  196.    char tempbuff[MAX_BUFFER_SIZE];
  197.    
  198.    // get procedures
  199.    
  200.    proclst = lprocedures();
  201.    
  202.    // pop them into the list box
  203.    
  204.    while (proclst != NIL)
  205.       {
  206.       cnv_strnode_string(tempbuff, proclst);
  207.       SendDlg